package test.net.rpc;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.log.StaticLog;
import com.wan.net.config.HostAndPort;
import com.wan.net.rpc.RpcManager;
import com.wan.net.rpc.invoker.RpcInvoker;
import com.wan.net.rpc.invoker.balancer.Balancer;
import com.wan.net.rpc.invoker.balancer.FirstBalancer;
import com.wan.net.rpc.invoker.balancer.IndexBalancer;
import com.wan.net.rpc.registry.ZookeeperRegistry;
import com.wan.net.rpc.service.RService;
import com.wan.util.serializer.ProtoStuffSerializer;

import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 * @author wwh
 * @date 2022/6/23 11:34
 */
public class RpcTestClient {

    public static void main(String[] args) throws Exception {
        RpcManager.setRegistry(new ZookeeperRegistry("127.0.0.1:2181"));
        Hello2 proxy = RpcInvoker.builder(Hello2.class).proxy();
        List<Integer> numbers = new ArrayList<>();
        numbers.add(211);
        numbers.add(985);
        numbers.sort(Comparator.comparing(Integer::intValue));

        int[] number = new int[5];
        number[0] = 1211;
        number[1] = 1985;
        number[2] = 1985123;
        number[3] = 9985123;
        number[4] = 1235123;

        String info = "你好啊啊啊啊发生范德萨富士达富士达啊啊沙发上撒飞洒发顺丰人登革热隔热隔热二哥额手" +
                "动 所谓认为 啊发生的飞洒的纷扰人爱人大师傅大师傅的个人为 士大夫但是粉色粉色 共三个人共同为七千" +
                "广东富豪桃花运try苦于睽睽路i路i六六路为222果热带扰动如图胡同一样痛苦与23让3的v下班吃饭吧" +
                "啊啊啊发生范德萨富士达富士达啊啊沙发上撒i路i六六路为222让他如果热带";
        String zing = proxy.zing(numbers, number, info);
        long time = System.currentTimeMillis();
        int index = 0;
        while (index < 10000){
            index ++;
            zing = proxy.zing(numbers, number, info);
        }
        System.out.println(index);
        System.out.println(System.currentTimeMillis() - time);
    }

}
